package com.dcsgo.myTankGameServers;

import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;

/**
 * @author DCSGO
 * @version 1.0
 * 游戏入口
 */
public class MyTankGame {
    public static String propertiesPath="src/com/dcsgo/myTankGameServers/common/setting.properties";
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        properties.load(new FileReader(propertiesPath));
        int port = Integer.parseInt(properties.getProperty("port"));
        ServerSocket serverSocket = new ServerSocket(port);
        int clientId = 0;
        while (true) {
            System.out.println("等待玩家连接...");
            Socket socket = serverSocket.accept();
            System.out.println("有玩家连接了！");
            new ServerConnectThread(clientId, socket).start();
            //将当前连接加入到 ClientSocketManage 中
            ClientSocketManage.put(clientId++, socket);

        }
    }
}
